package com.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class BaseUtil {

	/**
	 * MD5校验,返回的数据是Hex编码的
	 * 
	 * @param str
	 * @return
	 * @throws NoSuchAlgorithmException
	 */
	public static String getHex_MD5(String str) throws NoSuchAlgorithmException {
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		md5.update(str.getBytes());
		byte[] byteDigest = md5.digest();
		StringBuffer stringBuffer = new StringBuffer();
		for (byte b : byteDigest) {
			stringBuffer.append(Integer.toHexString((b & 0x000000FF) | 0xFFFFFF00).substring(6));
		}
		return stringBuffer.toString();
	}
}
